<template>
    <div class="food-container" v-if="isshow">
        <div class="food">
            <div class="img-head">
                <img v-lazy="food.image" alt="">
                <p class="foodpanel-desc">{{food.info}}</p>
                <div class="back" @click="toggleShow">
                    <i class="el-icon-arrow-left"></i>
                </div>
            </div>
            <div class="content">
                <div class="title">{{food.name}}</div>
                <div class="content-detail">
                    <span class="sell-month">月售{{food.sellCount}}份</span>
                    <span class="ratings">好评率{{food.rating}}</span>
                </div>
                <div class="bottom">
                    <div class="price">
                        <span class="now">￥{{food.price}}</span>
                    </div>
                    <div class="cartcontrol">
                        <cart-control :food="food"></cart-control>
                    </div>
                </div>
            </div>
        </div>
        <div class="food-cover" @click="toggleShow"></div>
    </div>
</template>

<script>
import CartControl from '../../components/CartControl/CartControl.vue'
export default {
    props:{
        food:Object
    },
    data () {
        return {
            isshow:false
        }
    },
    components:{
        CartControl,
    },
    methods:{
        toggleShow(){
            this.isshow = !this.isshow
        }
    }
}
</script>

<style lang="less" scoped>
.food-container{
    position: fixed;
    left: 0;
    top: 0;
    bottom: 48px;
    z-index: 101;
    width: 100%;
    .food{
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        width: 80%;
        height: 65%;
        z-index: 66;
        background: #fff;
        border-radius: 5px;
        .img-head{
            position: relative;
            padding-top: 100%;
            width: 100%;
            height: 0;
            img{
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
            .foodpanel-desc{
                position: absolute;
                letter-spacing: 0;
                font-size: 10px;
                bottom: 0;
                right: 0;
                left: 0;
                padding: 0 0 10px;
                color: #fff;
            }
            .back{
                position: absolute;
                top: 0;
                left: 0;
                padding: 10px 0 10px 0;
                font-size: 20px;
                color: #fff;
            }
        }
        .content{
            display: flex;
            flex-direction: column;
            padding-left: 18px;
            .title{
                font-size: 16px;
                font-weight: 700;
                margin-bottom: 10px;
                margin-top: 10px;
            }
            .content-detail{
                font-size: 13px;
                color: rgb(176, 175, 175);
                margin-top: 5px;
                margin-bottom: 20px;
            }
            .bottom{
                display: flex;
                justify-content: space-between;
                .price{
                    color: red;
                }
                .cartcontrol{ 
                    padding-bottom: 10px;
                    padding-right: 10px;
                }
            }
        }
    }
    .food-cover{
        position: absolute;
        top: 0;
        right: 0;
        bottom: -48px;
        left: 0;
        z-index: 55;
        background-color: rgba(0, 0, 0, 0.5);
    }
}
</style>